package cn.psvmc.cxzapi.response;


import cn.psvmc.cxzapi.enums.ResultCode;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {

    public static <T> Result<?> genSuccessResult() {
        return new Result<T>()
                .setCode(ResultCode.SUCCESS.getCode())
                .setMsg(ResultCode.SUCCESS.getMsg());
    }

    public static <T> Result<T> genSuccessResult(T data) {
        return new Result<T>(data)
                .setCode(ResultCode.SUCCESS.getCode())
                .setMsg(ResultCode.SUCCESS.getMsg());
    }

    public static <T> Result<T> genSuccessResult(String message, T obj) {
        return new Result<T>(obj)
                .setCode(ResultCode.SUCCESS.getCode())
                .setMsg(message);
    }

    public static <T> Result<T> genSuccessResult(String message) {
        return new Result<T>()
                .setCode(ResultCode.SUCCESS.getCode())
                .setMsg(message);
    }

    public static <T> Result<?> genFailResult() {
        return new Result<T>()
                .setCode(ResultCode.FAIL.getCode())
                .setMsg(ResultCode.FAIL.getMsg());
    }


    public static <T> Result<?> genFailResult(String message) {
        return new Result<T>()
                .setCode(ResultCode.FAIL.getCode())
                .setMsg(message);
    }

    public static <T> Result<?> genFailResult(ResultCode resultCode) {
        return new Result<T>()
                .setCode(resultCode.getCode())
                .setMsg(resultCode.getMsg());
    }

    public static <T> Result<?> genFailResult(ResultCode resultCode, String message) {
        return new Result<T>()
                .setCode(resultCode.getCode())
                .setMsg(message);
    }

}
